This invention relates generally to databases, such as in-memory databases (IMDB""s), and particularly to clearing share latches on sections of such database that may still be asserted upon the termination of their asserting client processes.
Databases, such as in-memory databases (IMDB""s), generally allow for a number of different processes to access the database at once. A database may be divided into different sections, or pages. A process may therefore xe2x80x9clatch,xe2x80x9d or assert a latch on, a section of the database while it accesses the section, so that the data residing in the section cannot be modified while the process accesses it.
Different types of processes may resort to different types of latches for accessing the database. For example, a core process can be non-restrictively defined as an operating system or other process by which database data can be modified. Such a core process may be able to assert an exclusive latch on a database section, so that they are able to read from and write to the section without any other process accessing the data.
Other processes can be non-restrictively defined as client processes which are able to access but not modify database data. Such client processes may be able to assert a share latch on a database section, so that they are able to read from the section. The latches are share latches in that other share latches of other processes can access the database section at the same time. Because share latches do not allow their asserting processes to modify the data, simultaneous or concurrent access is permissible.
Generally, when a core process needs to assert an exclusive latch on a database section, it must first wait for any share latches on the section to be released. This is because the assertion of the exclusive latch implies that modification to the data in the database section may occur, which is problematic if other processes are accessing the data at the same time via share latches. Therefore, a core process may first signal its intention to assert an exclusive latch on the database section, so that no new share latches are asserted on the section. The core process then waits for existing share latches to be released prior to asserting its exclusive latch.
A difficulty arises, however, when a client process is terminated prior to releasing any share latches it had asserted on sections of the database. Unless these share latches are cleared, a core process may not be able to assert exclusive latches on the database sections. A client process may terminate prior to releasing its share latches because it unexpectedly crashed or otherwise terminated in an irregular manner; because the client process may be poorly coded, such that it terminates normally, but without first clearing its share latches; etc.
For this and other reasons, there is a need for the present invention.
The invention relates to clearing share latches for databases, such as in-memory databases. In one embodiment, a computerized system includes a database, a client process and a core process. The database has a number of sections, and can be an in-memory database. The client process is capable of asserting a share latch on a section of the database, where in one embodiment the share latch permits the client process to have shared read-only access to the section. The core process is capable of asserting an exclusive latch on a section of the database, where in one embodiment the exclusive latch permits the core process to have exclusive read-and-write access to the section. The core process is further capable of clearing the share latch asserted by the client process, upon termination of the client processxe2x80x94unexpected or otherwisexe2x80x94while the share latch is still asserted.
In one embodiment, a latch log is associated with a client process. The latch log has a number of entries. Each entry can have a latch flag indicating whether the client process has asserted a share latch corresponding to the entry, as well as a pointer or other reference to a section of memory against which the share latch has been asserted. In one embodiment, the latch flag is false, and the reference contains a null value, if an entry does not correspond to an active share latch of the process. However, the client process may unexpectedly terminatexe2x80x94for example, it may xe2x80x9ccrashxe2x80x9dxe2x80x94such that the reference points to a memory section while the latch flag is false. Thus, one embodiment of the invention is able to determine whether a share latch is still asserted on the section, taking into account potential occurrence that the latch flag of the entry is incorrect.
The invention includes computer-implemented methods, machine-readable media, computerized systems, and computers of varying scopes. Other aspects, embodiments and advantages of the invention, beyond those described here, will become apparent by reading the detailed description and with reference to the drawings.